/**
 * AUTHOR: Zhou Yu <pepsior@163.com>
 *
 * COPYRIGHT(C) 2011 Zhou Yu. ALL RIGHTS RESERVED.
 */
#pragma once
#ifndef XL_PATCH_H_INCLUDED
#define XL_PATCH_H_INCLUDED

#include <xl/version.h>

/* Patch Length */
#define XL_PATCH_LENGTH         5

/* Patch */
typedef struct xl_patch
{
    xl_version_t version;
    size_t offset;
    const unsigned char source[XL_PATCH_LENGTH];
    const unsigned char dest[XL_PATCH_LENGTH];
}xl_patch_t;

/* Find the patch of specified version. */
xl_patch_t *xl_patch_find(const xl_version_t *version);

/* Get the offset of patch. */
__inline static size_t xl_patch_get_offset(const xl_patch_t *patch)
{
    return patch->offset;
}

/* Get the source data of patch. */
__inline static const unsigned char *xl_patch_get_source(const xl_patch_t *patch)
{
    return patch->source;
}

/* Get the destination data of patch. */
__inline static const unsigned char *xl_patch_get_dest(const xl_patch_t *patch)
{
    return patch->dest;
}

#endif      /* #ifndef XL_PATCH_H_INCLUDED */

